
<div class="grid_6">

<?php if (is_array($message)) : ?>
<div class="alpha omega prefix_1 grid_5 messages <?php echo $message['class']; ?>"><?php echo $message['text']; ?></div>
<?php endif; ?>

<?php if (!empty($allPosts)) : ?>

<?php if (isset($searchTerms)) : ?>
	<h2 class="alpha prefix_2 grid_4 omega search-results"><?php echo sizeof($allPosts); ?> posts for <strong><?php echo $searchTerms; ?></strong></h2>
<?php endif; ?>

<?php foreach ($allPosts as $post) : ?>

<?php if (!is_null($post->getTweetId())) : ?>

    <div class="tweet-icon prefix_1 grid_1 alpha"><img src="/img/twitter-bird.png" /></div>
	<div class="tweet grid_4 omega">
		<div class="tweet-content">
			<a class="author" href="http://twitter.com/<?php echo $post->getAuthorTwitterScreenName(); ?>"><?php echo $post->getAuthorName(); ?></a>:
			<?php echo $post->getContent(); ?>

		</div>
		<div class="tweet-date">
			<a href="http://twitter.com/<?php echo $post->getAuthorTwitterScreenName(); ?>/status/<?php echo $post->getTweetId(); ?>" class="tweet-timestamp"><?php echo date('j M Y', $post->getDateCreated()) . ' &middot; ' . date('g:iA', $post->getDateCreated()); ?></a>
		</div>
    </div>
	<div class="clear"></div>
    
<?php else : ?>

	<h2 class="alpha prefix_2 grid_4 omega"><?php echo anchor('/post/' . $post->getSlug(), $post->getTitle()); ?></h2>
	<div class="post-metadata grid_2 alpha">
		<div class="post-author">by <?php echo $post->getAuthorName(); ?></div>
		<div class="post-date"><?php echo $post->getDateCreatedLocal(); ?></div>
		<div class="post-comments">
            <?php echo anchor('post/' . $post->getSlug() . '#comments', $post->getCommentCount() . ' comments'); ?>
            &middot; <?php echo anchor('post/' . $post->getSlug(), 'Permalink'); ?></div>
	</div>	
	<div class="post grid_4 omega">
        <?php echo $post->getContent(); ?>
	</div>
	<div class="clear"></div>
    
<?php endif; ?>

<?php endforeach; ?>

	<div class="alpha omega prefix_2 grid_4">
<?php if ($hasEarlierPosts) : ?>
		<div id="pagination-earlier" class="alpha grid_2">
			<?php echo anchor('home/' . ($currentPage + 1), '&laquo; Earlier Posts'); ?>
		</div>
<?php endif; ?>

<?php if ($hasLaterPosts) : ?>
		<div id="pagination-later" class="<?php echo ($hasEarlierPosts ? '' : 'alpha prefix_2'); ?> grid_2 omega">
			<?php echo anchor('home/' . ($currentPage - 1), 'Later Posts &raquo;'); ?>
		</div>
<?php endif; ?>
	</div>

<?php else : ?>

	<h2 class="alpha grid_5 omega">No posts<?php if (isset($searchTerms)) echo ' for \'' . $searchTerms . '\''; ?>.</h2>

<?php endif; ?>
	
</div>

<div class="grid_3 sidebar">
	
	<div class="sidebar-contents">

		<div class="sidebar-item search-box">
			<input id="ligature-search-input" type="text" /><button onclick="postSearch('<?php echo site_url('search'); ?>');">Search</button>
		</div>

		<div class="sidebar-item">
				<h3>Meta</h3>
				<ul>
<?php if ($this->session->userdata('current_user_name') !== false) : ?>
<?php if ($this->session->userdata('is_admin')) : ?>
					<li><?php echo anchor('editPost', 'Write new post'); ?></li>
<?php endif; ?>
					<li><?php echo anchor('logout', 'Log out'); ?></li>
<?php else : ?>
					<li><?php echo anchor('auth', 'Log in'); ?></li>
					<li><?php echo anchor('auth/forceLogin', 'Log in with reauth'); ?></li>
<?php endif; ?>
				</ul>
		</div>
		
		<div class="sidebar-item">
			<h3>Recent comments</h3>
<?php if (!empty($recentComments)) : ?>
<?php foreach ($recentComments as $comment) : ?>
			<div class="recent-comment">
				<div class="recent-comment-excerpt">
					<span class="recent-comment-author"><?php echo $comment->getAuthorName(); ?></span>
					<?php echo $this->clickframes->truncate($comment->getComment(), 150); ?>
				</div>
				<div class="recent-comment-link">
					<?php echo anchor('post/' . $comment->getPostSlug() . '#comment-' . $comment->getCommentId(), $comment->getPostTitle()); ?>
				</div>
			</div>
<?php endforeach; ?>
<?php else : ?>
			<p>No recent comments.</p>
<?php endif; ?>
		</div>
        
    </div>
	
</div>
<div class="clear"></div>
<?php /* clickframes::version=2747817656::clickframes */ ?>